package com.eonmind.ai.dto;

import com.eonmind.common.contract.data.request.PageRequest;
import com.eonmind.common.contract.enums.ai.AiArtworkStatusEnum;
import com.eonmind.common.contract.timer.Timer;
import com.mongoplus.annotation.index.MongoIndex;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.ToString;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;

import java.util.ArrayList;
import java.util.List;

public class AiDrawDto {
    @Data
    @ToString
    public static class AiDrawMjTaskRequest {
        /**
         * 垫图的base64数组
         */
        private List<String> base64Array;

        /**
         * 绘画Prompt
         */
        @NotBlank
        private String prompt;

        /**
         * 宽度
         *
         * @mock 9:16
         */
        @NotBlank
        @Pattern(regexp = "^\\d+:\\d+$")
        private String ratio;
    }

    @Data
    @ToString
    public static class AiDrawTaskQueryRequest {
        /**
         * 绘画任务ID
         */
        private Long id;
    }

    /**
     * 绘画任务删除请求
     */
    @Data
    @ToString
    public static class DrawTaskDelRequest {
        /**
         * 绘画任务ID
         */
        @NotNull(message = "id不能为空")
        private Long id;
    }

    /**
     * 绘画任务查询返回
     */
    @Data
    @ToString
    public static class MjDrawTaskQueryResponse {
        /**
         * 绘画任务id
         */
        private Long id;


        /**
         * 绘画任务提示词
         */
        private String prompt = "";


        /**
         * 图片比例
         */
        private String ratio = "";


        /**
         * 绘画任务图片数量
         */
        @MongoIndex
        private Integer imgNum = 1;

        /**
         * 绘画任务图片地址
         * Mj 只有一张
         */
        @MongoIndex
        private List<String> imgList = new ArrayList<>();

        /**
         * 绘画任务进度
         */
        private String progress = "0%";

        /**
         * 失败原因
         */
        private String failReason = "";


        /**
         * 绘画任务状态
         * 0:待生成 1:生成中 2:生成成功 3:生成失败
         */
        @MongoIndex
        private Integer status = AiArtworkStatusEnum.PENDING_GENERATION.getCode();

        /**
         * 创建时间
         */
        private Long createTime = Timer.currentTimestamp();

        /**
         * 更新时间
         */
        private Long updateTime = Timer.currentTimestamp();

        /**
         * 按钮
         */
        private List<Button> buttons = new ArrayList<>();

        @Data
        @ToString
        public static class Button {

            /**
             * 自定义按钮id
             */
            private String customId;

            /**
             * 按钮文本
             */
            private String label;

            /**
             * 样式: 2（Primary）、3（Green）
             */
            private Integer style;

            /**
             * 类型，系统内部使用
             */
            private Integer type;
        }

    }


    @Data
    @ToString
    public static class AiDrawPageRequest {
        /**
         * 分页信息
         */
        private PageRequest page = new PageRequest();
    }

    @Data
    @ToString
    public static class AiDrawMjCommandRequest {
        /**
         * 绘画ID
         */
        private Long id;
        /**
         * 绘画命名CustomID
         */
        private String customId;
    }

    @Data
    @ToString
    public static class AiDrawMjTaskSyncRequest {
        /**
         * 绘画任务id
         */
        @NotNull
        private Long id;
    }
}
